package com.miaoquan.mqportal.controller;

import com.miaoquan.mqcommon.api.CommonPage;
import com.miaoquan.mqcommon.api.CommonResult;
import com.miaoquan.mqmbg.model.TbkProduct;
import com.miaoquan.mqportal.feign.SearchFeign;
import com.taobao.api.request.TbkDgMaterialOptionalRequest;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 淘宝客搜索Controller
 *
 * @author Fa
 * @date 2020-04-04 22:57
 */
@Api(tags = {"淘宝客搜索"})
@RestController
@RequestMapping("/search")
public class TbkSearchController {

    @Autowired
    private SearchFeign searchFeign;

    /**
     * 商品搜索
     */
    @GetMapping("/product")
    public CommonResult<CommonPage<TbkProduct>> searchProduct(
            @RequestParam(required = false, defaultValue = "1") Long pageNum, boolean isTmall, @RequestParam String q) {
        return searchFeign.searchProduct(pageNum, isTmall, q);
    }

    /**
     * 价格筛选
     */
    @PostMapping("/product/all")
    public CommonResult<CommonPage<TbkProduct>> searchProduct(
            @RequestBody TbkDgMaterialOptionalRequest tbkDgMaterialOptionalRequest) {
        return searchFeign.searchProduct(tbkDgMaterialOptionalRequest);
    }

}
